package work;

public class Test1 {
    public static void main(String[] args) {
        String str = "NIwUOy";
        StringBuffer stringBuffer = new StringBuffer();
        StringBuilder stringBuilder = new StringBuilder();

        char[] arr = str.toCharArray();

        int m = str.length();  //6
        for (int i = str.length() - 1; i >= 0; i--) {

            if (arr[i] >= 'a' && arr[i] <= 'z') {
                String sub = str.substring(i,i + 1);
                sub = sub.toUpperCase();
                stringBuilder = stringBuilder.append(sub);
            }
            if (arr[i] >= 'A' && arr[i] <= 'Z') {
                String sub = str.substring(i,i + 1);
                sub = sub.toLowerCase();
                stringBuilder = stringBuilder.append(sub);
            }
        }
        for (int i = 0; i < str.length() ; i++) {
            arr[i] = str.charAt(i);
            stringBuffer = stringBuffer.append(arr[i]);
        }

        System.out.println(stringBuilder.toString());
        System.out.println(stringBuffer.toString());

    }
}
